#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

const int N = 1e6 + 10, M = 5e4 + 10;

bool f[N], st[M];
int prime[M], cnt;
LL q[M];

void init(int n){
    for(int i = 2; i <= n; i ++){
        if(!st[i]) prime[cnt ++] = i;

        for(int j = 0; prime[j] <= n / i; j ++){
            st[prime[j] * i] = true;
            if(i % prime[j] == 0) break;
        }
    }
}

void look(){
    for(int i = 0; i <= 15; i ++){
        printf("%d ", f[i]);
    }
    printf("\n");
}

LL upb(LL l, int i){
    if(l % prime[i] == 0){
        return l / prime[i] * prime[i];
    }else{
        return (l + prime[i]) / prime[i] * prime[i];
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    init(50000);

    LL l, r;
    while(cin >> l >> r){
        memset(f, 0, sizeof f);
        if(l == 1)f[0] = true;
        for(int i = 0; i < cnt; i++){
            for(int j = max((LL)prime[i] * 2, upb(l, i)) - l; j <= r - l; j += prime[i]){
                f[j] = true;
                // cout << j << " ";
            }
        }
        // cout << endl;

        // look();

        int tt = -1;
        for(int i = 0; i <= r - l; i ++){
            if(!f[i]){
                q[++tt] = i + l;
            }            
        }

        if(tt < 1){
            printf("There are no adjacent primes.\n");
        }else{
            LL minv = 1e18, maxv = 0;
            LL k1 = 0, k2 = 0;
            for(int i = 0; i < tt; i ++){
                if(minv > q[i + 1] - q[i]){
                    minv = q[i + 1] - q[i];
                    k1 = i;
                }
                if(maxv < q[i + 1] - q[i]){
                    maxv = q[i + 1] - q[i];
                    k2 = i;
                }
            }
            printf("%lld,%lld are closest, %lld,%lld are most distant.\n", q[k1], q[k1 + 1], q[k2], q[k2 + 1]);
        }

        
    }


    return 0;
}